 var Swiper = require("swiper");
require("swiper/dist/css/swiper.min.css");
var Lun= React.createClass({
	render : function(){
		return (<a  className="swiper-slide">
							 <p>{this.props.data.p1}</p>
							 <p>{this.props.data.p2}</p>
				</a>
				 )
	}
})

export default React.createClass({
	getInitialState:function(){
		return {
			state :[
				{
					p1 : "【七夕】爱不在七夕这一天，茶窝陪伴您每一天",
					p2 :"【新品】臻品黄印生茶新品上市"
				},
				{
					p1 : "【积分】积分兑换上线了！~~",
					p2 :"【公告】茶窝网服务系统升级"
				},
				{
					p1 : "【套餐】新手入门 经典系列",
					p2 :"【预售】下关尚品金丝饼茶 火爆预售中"
				}
			]
		}
	},
	getDefaultProps:function(){
		return {
			className : "swiper-container2"
		}
	},
	swiper : null,
	componentDidMount : function(){
        var that = this;
        this.swiper = new Swiper( "."+that.props.className, {
            autoplay : 2000,
            loop : true,
            direction:"vertical"
    
        });
    },
    componentDidUpdate(){
         this.swiper.update();
    },
	render : function(){
		var Newlun = this.state.state.map(function(data,index){
			return <Lun key={index} data={data}/ >
		})
		var className = this.props.className == "swiper-container2" ? "swiper-container2" : this.props.className;
		return (
			<div className="home_banner2">
				<img src="images/toutiao.jpg" />
				<div className = {className}>
					<div className="swiper-wrapper">
						  {Newlun}	
					</div> 
				</div>
			</div>
		)
	}
})
 
